package com.huicoo.forestmanager.ui.patrol.forestCampTask;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.Color;
import android.location.LocationManager;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.huicoo.forestmanager.CustomUtils;
import com.huicoo.forestmanager.R;
import com.huicoo.forestmanager.adapter.PatrolRecordAdapter;
import com.huicoo.forestmanager.network.bean.patrol.GetMyForestZoneBean;
import com.huicoo.forestmanager.network.bean.patrol.PatrolEventEntity;
import com.huicoo.forestmanager.network.bean.patrol.RecorddetailsBean;
import com.huicoo.forestmanager.network.bean.patrol.ReportPointEntity;
import com.huicoo.forestmanager.network.bean.patrol.StartPatrolBean;
import com.huicoo.forestmanager.others.WebRefreshEvent;
import com.huicoo.forestmanager.service.ForegroundService;
import com.huicoo.forestmanager.ui.patrol.InspectionRecordActivity;
import com.huicoo.forestmanager.ui.patrol.forestCampTask.contract.ForestCampTaskContract;
import com.huicoo.forestmanager.ui.patrol.forestCampTask.presenter.ForestCampTaskPresenter;
import com.huicoo.forestmanager.util.LogUtils;
import com.huicoo.forestmanager.util.MulchUtil;
import com.huicoo.forestmanager.util.StringUtil;
import com.huicoo.forestmanager.util.TimeFormatUtil;
import com.huicoo.forestmanager.util.WeakHandler;
import com.huicoo.forestmanager.util.toast.ToastUtils;
import com.huicoo.forestmanager.widget.LoadingDialog;
import com.tianditu.android.maps.GeoPoint;
import com.tianditu.android.maps.TErrorCode;
import com.tianditu.android.maps.TGeoAddress;
import com.tianditu.android.maps.TGeoDecode;
import com.tianditu.android.maps.overlay.PolylineOverlay;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * --------- 日期 ------- 维护人 ------------ 变更内容 --------
 * 2019/4/7		    Administrator
 * 进行巡查任务
 */
public class ForestCampTaskActivity extends BaseForestCampMapActivity implements ForestCampTaskContract.View, Handler.Callback, TGeoDecode.OnGeoResultListener {

    @BindView(R.id.tab_Layout)
    TabLayout tab_Layout;
    @BindView(R.id.view_pager)
    ViewPager view_pager;
    @BindView(R.id.ll_prepare)
    LinearLayout ll_prepare;
    @BindView(R.id.ll_doing_panel)
    LinearLayout ll_doing_panel;
    @BindView(R.id.tv_detail_title)
    TextView tv_detail_title;
    @BindView(R.id.tv_detail_desc)
    TextView tv_detail_desc;
    @BindView(R.id.btn_start)
    TextView btn_start;
    @BindView(R.id.btn_over)
    TextView btn_over;

    private static final int MSG_RESET_TIME = 101;
    private static final int MSG_COLLECT_POINT = 102;

    private String taskRecordId; //巡查id
    private ArrayList<GeoPoint> geoPoints; //林地区域坐标列表
    private List<PatrolEventEntity> eventList; //待核实事件列表
    private PolylineOverlay historyTrajectory; //历史轨迹覆盖物

    private boolean isTaskRunning; //任务是否正在进行中
    private ReportPointEntity lastReportPoint; //上一个上报的坐标点
    private ReportPointEntity toReportPoint; //待上报的坐标点
    private WeakHandler handler;

    private TaskUploadContainerFragment taskUploadContainerFragment;
    private NeedVerifyProblemContainerFragment needVerifyProblemContainerFragment;
    private LoadingDialog loadingDialog;
    private MyServiceConnection conn;
    private ForegroundService.MyBinder myBinder;

    // 采集坐标的间隔时间
    private int collectDuring = 10;
    //上报距离间隔下限
    private double tolerance = 5;
    //上报距离间隔上限
    private double maxTolerance = 50;

    private TGeoDecode mGeoDecode;
    //结束巡查的坐标点
    private GeoPoint stopPatrolPoint;

    //测试，记录请求上报坐标的点
    private List<ReportPointEntity> requestPoints;
    //测试，记录响应上报坐标的点
    private List<ReportPointEntity> responsePoints;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_forest_camp_task;
    }

    @Override
    protected void initView() {
        super.initView();
        initTabLayoutAndViewPager();

        handler = new WeakHandler(this);
        loadingDialog = new LoadingDialog(this);
        presenter = new ForestCampTaskPresenter(this);

        initService();

        initData();

        requestPoints = new ArrayList<>();
        responsePoints = new ArrayList<>();
    }

    private void initDetail(GetMyForestZoneBean.GetMyForestZoneData data) {
        //地图画林地区域
        mapDrawForestZone(data.Coordinates, data.EventInfos, data.TreeInfos);

        String area = StringUtil.formatArea(data.Acreage);
        tv_detail_title.setText(String.format("责任区面积%s  历史平均用时%s", area, TimeFormatUtil.formatHMS(data.AverageDuration)));
        eventList = data.EventInfos;
        tv_detail_desc.setText(String.format("责任区未结案事件%s件", data.EventNum));
        //设置未结案事件的tab的显示
        resetProblemTab(String.valueOf(data.EventNum));
    }

    private void mapDrawForestZone(List<List<RecorddetailsBean.Data.Coordinates>> coordinates, List<PatrolEventEntity> eventInfos, List<GetMyForestZoneBean.ForestMulchInfo> treeInfos) {
        //画林地区域
        geoPoints = new ArrayList<>();
        if (coordinates != null) {
            for (List<RecorddetailsBean.Data.Coordinates> dataList : coordinates) {
                ArrayList<GeoPoint> perPointList = new ArrayList<>();
                for (RecorddetailsBean.Data.Coordinates Coordinate : dataList) {
                    GeoPoint mPoint = new GeoPoint((int) (Coordinate.getLatitude() * 1E6), (int) (Coordinate.getLongitude() * 1E6));
                    perPointList.add(mPoint);
                    geoPoints.add(mPoint);
                }
                MulchUtil.addPolygonMulch(map_view, perPointList);
            }
        }
        //定位到中心点
        if (geoPoints != null && !geoPoints.isEmpty()) {
            MulchUtil.locatePolygonMulchCenter(map_view, geoPoints);
        }
        //画事件位置
        if (eventInfos != null) {
            for (PatrolEventEntity info : eventInfos) {
                try {
                    GeoPoint point = new GeoPoint((int) (info.getLatitude() * 1E6), (int) (info.getLongitude() * 1E6));
                    MulchUtil.addCustomImgMulch(getApplicationContext(), map_view, point, R.mipmap.map_marker_event);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        //画名贵树木
        if (treeInfos != null) {
            for (GetMyForestZoneBean.ForestMulchInfo info : treeInfos) {
                try {
                    GeoPoint point = new GeoPoint((int) (info.CoordinateEntity.getLatitude() * 1E6), (int) (info.CoordinateEntity.getLongitude() * 1E6));
                    MulchUtil.addCustomImgMulch(getApplicationContext(), map_view, point, R.mipmap.map_marker_tree);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }

    private void initTabLayoutAndViewPager() {
        //(片段得到支持经理)
        PatrolRecordAdapter pageAdapter = new PatrolRecordAdapter(getSupportFragmentManager());
        taskUploadContainerFragment = TaskUploadContainerFragment.getInstance();
        taskUploadContainerFragment.setOnTaskUploadListener(new TaskUploadContainerFragment.OnTaskUploadListener() {
            @Override
            public void finishTask(boolean toReportRecord) {
                requestStopPatrol(toReportRecord);
            }

            @Override
            public GeoPoint getCurrentGeoPoint() {
                return locateCurrentLocation(null);
            }
        });
        needVerifyProblemContainerFragment = NeedVerifyProblemContainerFragment.getInstance();
        pageAdapter.addFragmentPager("已耗时0分0秒", taskUploadContainerFragment);//片段
        pageAdapter.addFragmentPager("需进一步核实的问题(0)", needVerifyProblemContainerFragment);//片段
        view_pager.setAdapter(pageAdapter);//设置适配器
        view_pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int i, float v, int i1) {

            }

            @Override
            public void onPageSelected(int i) {
                //设置未结案事件数据
                if (i == 1 && needVerifyProblemContainerFragment != null && eventList != null && !eventList.isEmpty()) {
                    needVerifyProblemContainerFragment.initSetData(eventList);
                }
            }

            @Override
            public void onPageScrollStateChanged(int i) {

            }
        });
        //标签布局绑定视图页
        tab_Layout.setupWithViewPager(view_pager);
    }

    //初始化前台进程服务
    private void initService() {
        Intent service = new Intent(this, ForegroundService.class);
        conn = new MyServiceConnection();
        bindService(service, conn, Context.BIND_AUTO_CREATE);
    }

    //获取初始数据
    private void initData() {
        loadingDialog.show();
        //请求林长负责林地信息
        {
            HashMap<String, String> params = new HashMap<>();
            params.put("Token", CustomUtils.getToken());
            ((ForestCampTaskPresenter) presenter).getMyForestZone(params, false);
        }
        // 请求获取任务详情
//        {
//            HashMap<String, String> params = new HashMap<>();
//            params.put("Token", CustomUtils.getToken());
//            params.put("RecordId", taskRecordId);
//            ((ForestCampTaskPresenter) presenter).getTaskDetails(params);
//        }

        // 请求上报位置时间间隔
        {
            HashMap<String, String> params = new HashMap<>();
            params.put("Token", CustomUtils.getToken());
            ((ForestCampTaskPresenter) presenter).getReportTimeSpan(params);
        }
    }

    //启动前台服务
    private void startForeGround() {
        if (myBinder != null) {
            myBinder.start();
        }
    }

    //关闭前台服务
    private void stopForeGround() {
        if (myBinder != null) {
            myBinder.stop();
        }
    }

    @OnClick(R.id.back)
    public void back() {
        onBackPressed();
    }

    @OnClick(R.id.btn_start)
    public void startPatrol() {
        //检查是否开启GPS
        if (!checkOpenGPS()) {
            return;
        }
        requestStartPatrol();
    }

    @OnClick(R.id.btn_over)
    public void reviewPatrol() {
        patrolOver();
    }

    //检查是否开启GPS
    private boolean checkOpenGPS() {
        LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE);
        boolean isOpenGPS = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
        if (!isOpenGPS) {
            ToastUtils.show("系统检测到未开启GPS定位服务");
            Intent intent = new Intent();
            intent.setAction(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            startActivity(intent);
        }
        return isOpenGPS;
    }

    //回到
    @OnClick(R.id.turn_back)
    public void turnBack() {
        if (geoPoints != null && !geoPoints.isEmpty()) {
            //中心定位
            MulchUtil.locatePolygonMulchCenter(map_view, geoPoints);
        }
    }

    //请求开始巡查任务
    private void requestStartPatrol() {
        GeoPoint point = locateCurrentLocation(null);
        if (point == null) {
            ToastUtils.show("无法获取当前位置，请检查是否开启GPS位置信息");
            return;
        }
        loadingDialog.show();
        HashMap<String, String> params = new HashMap<>();
        params.put("Token", CustomUtils.getToken());
        params.put("accuracy", getCurrentAccuracy());
        params.put("longitude", formatPoint(point.getLongitudeE6()));
        params.put("latitude", formatPoint(point.getLatitudeE6()));
        ((ForestCampTaskPresenter) presenter).startTask(params);
    }

    //请求上报坐标
    private void requestReportPoint(ReportPointEntity entity) {
        HashMap<String, String> params = new HashMap<>();
        params.put("Token", CustomUtils.getToken());
        params.put("RecordID", taskRecordId);
        params.put("accuracy", getCurrentAccuracy());
        params.put("longitude", entity.getLongitude());
        params.put("latitude", entity.getLatitude());
        params.put("time", entity.getTime());
        params.put("IsCheckRepeat", "1");
        params.put("UID", entity.getUUID());
        ((ForestCampTaskPresenter) presenter).reportPosition(params, entity);
    }

    //请求结束巡查任务
    private void requestStopPatrol(boolean toReportRecord) {
        //结束前最后记录当前位置再提交
        GeoPoint point = locateCurrentLocation(null);
        if (point == null) {
            ToastUtils.show("无法获取当前位置，请检查是否开启GPS位置信息");
            return;
        }
        loadingDialog.show();
        HashMap<String, String> params = new HashMap<>();
        params.put("Token", CustomUtils.getToken());
        params.put("RecordID", taskRecordId);
        params.put("accuracy", getCurrentAccuracy());
        params.put("longitude", formatPoint(point.getLongitudeE6()));
        params.put("latitude", formatPoint(point.getLatitudeE6()));
        params.put("IsCheckRepeat", "1");
        params.put("UID", CustomUtils.getUUID());
        ((ForestCampTaskPresenter) presenter).stopTask(params, toReportRecord);
        //记录结束巡查的坐标
        stopPatrolPoint = point;
    }

    //设置时间tab的显示
    private void resetTimeTab(int second) {
        TabLayout.Tab tab = tab_Layout.getTabAt(0);
        if (tab != null) {
            String time = String.format("已耗时%s", TimeFormatUtil.formatHMS(second));
            tab.setText(time);
        }
    }

    //设置核实问题的tab的显示
    private void resetProblemTab(String problemNum) {
        TabLayout.Tab tab = tab_Layout.getTabAt(1);
        if (tab != null) {
            String content = String.format("责任区未结案事件(%s)", problemNum);
            SpannableStringBuilder stringBuilder = new SpannableStringBuilder(content);
            ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(Color.parseColor("#25B3D3"));
            stringBuilder.setSpan(foregroundColorSpan, 9, 9 + problemNum.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            tab.setText(stringBuilder);
        }

    }

    //任务开始，触发轮询上报位置坐标
    private void patrolPointUpdate() {
        //开启前台服务
        startForeGround();
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onDestroy() {
        unbindService(conn);
        super.onDestroy();
    }

    @Override
    public void onBackPressed() {
        if (isTaskRunning) {
            ToastUtils.show("巡查任务进行中，退出请先结束巡查");
            return;
        }
        super.onBackPressed();
    }

    @Override
    public void getMyForestZoneSuccess(GetMyForestZoneBean.GetMyForestZoneData Data) {
        if (loadingDialog != null) {
            loadingDialog.dismiss();
        }
        if (Data != null) {
            initDetail(Data);
        }
    }

    @Override
    public void refreshEvent(List<PatrolEventEntity> mEventList) {
        try {
            this.eventList = mEventList;
            //刷新未结案事件数据
            if (needVerifyProblemContainerFragment != null && eventList != null && !eventList.isEmpty()) {
                needVerifyProblemContainerFragment.setData(eventList);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    // 获取任务详情数据
    @Override
    public void getTaskDetailsSuccess(RecorddetailsBean.Data Data) {
        if (loadingDialog != null) {
            loadingDialog.dismiss();
        }
        if (Data != null) {
            try {
                List<RecorddetailsBean.Data.Coordinates> coordinates = Data.getCoordinates();
                if (coordinates != null && !coordinates.isEmpty()) {
                    historyTrajectory = MulchUtil.drawTheRangerTrajectory2(map_view, coordinates);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    // 获取巡查任务上报位置间隔时间
    @Override
    public void getReportTimeSpan(int during, double tolerance, double maxTolerance) {
        collectDuring = during;
        if (tolerance > 0) {
            this.tolerance = tolerance;
        }
        if (maxTolerance > 0) {
            this.maxTolerance = maxTolerance;
        }
    }

    // 开始巡查任务  成功
    @Override
    public void startTaskSuccess(StartPatrolBean.StartPatrolData Data) {
        loadingDialog.dismiss();
        if (Data != null) {
            this.taskRecordId = String.valueOf(Data.RecordID);
            if (!Data.IsNew) {
                ToastUtils.show("继续上次未完成巡查任务");
            }
            //开始巡查
            patrolling();
        } else {
            ToastUtils.show("未找到巡查任务ID");
        }
    }

    private void patrolling() {
        if (taskUploadContainerFragment != null) {
            taskUploadContainerFragment.setRecordId(taskRecordId);
            taskUploadContainerFragment.setButtonShow(true);
        }
        //开始巡查
        isTaskRunning = true;
        ll_prepare.setVisibility(View.GONE);
        ll_doing_panel.setVisibility(View.VISIBLE);
        //任务开始，触发轮询上报位置
        patrolPointUpdate();
        //地图zoom最大
        setZoom(18);

        //清除历史轨迹
        if (historyTrajectory != null) {
            map_view.removeOverlay(historyTrajectory);
        }
    }

    private void patrolOver() {
        if (taskUploadContainerFragment != null) {
            taskUploadContainerFragment.setRecordId(taskRecordId);
            taskUploadContainerFragment.setButtonShow(false);
        }
        ll_prepare.setVisibility(View.GONE);
        ll_doing_panel.setVisibility(View.VISIBLE);
    }

    // 巡查任务上报位置 成功
    @Override
    public void reportPositionSuccess(ReportPointEntity entity) {
        LogUtils.v("gogogo 上报位置成功");
        responsePoints.add(entity);

        // 删除已上报的坐标
        toReportPoint = null;
    }

    // 结束巡查任务  成功
    @Override
    public void stopTaskSuccess(boolean toReportRecord) {
        isTaskRunning = false;
        loadingDialog.dismiss();
        toReportPoint = null;
        //关闭前台服务
        stopForeGround();

        //是否跳转报送记录页面
        if (toReportRecord) {
            //巡查记录报送
            if (stopPatrolPoint == null) {
                stopPatrolPoint = locateCurrentLocation(null);
            }
            //获取结束巡查位置的地址
            searchGeoDecode(stopPatrolPoint);
        } else {
            finish();
        }

//        File requestFile = new File(AttachmentHelper.getFilePath("request.txt"));
//        saveFile(requestFile, JsonUtils.toJson(requestPoints));

//        File responseFile = new File(AttachmentHelper.getFilePath("response.txt"));
//        saveFile(responseFile, JsonUtils.toJson(responsePoints));
    }

    private void saveFile(File file, String json) {
        FileWriter fr = null;
        try {
            fr = new FileWriter(file);
            fr.write(json);
            fr.flush();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (fr != null) {
                    fr.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    public void fail(String msg) {
        loadingDialog.dismiss();
        ToastUtils.show(TextUtils.isEmpty(msg) ? "请求失败，请重试" : msg);
    }

    /**
     * 前台服务连接，自定义一个类，实现ServiceConnection接口，并重写其两个方法
     */
    public class MyServiceConnection implements ServiceConnection {
        //当绑定服务成功的时候会调用此方法
        public void onServiceConnected(ComponentName name, IBinder service) {
            //得到MyService.MyBinder对象，我们通过这个对象来操作服务中的方法
            myBinder = (ForegroundService.MyBinder) service;

            ForegroundService foregroundService = myBinder.getService();
            //实现回调，得到实时刷新的数据
            foregroundService.setCallback(new ForegroundService.Callback() {

                @Override
                public void resetTime(int second) {
//                    LogUtils.v("gogogo second = " + second);
                    //更新tab时间显示
                    Message timeMessage = new Message();
                    timeMessage.what = MSG_RESET_TIME;
                    timeMessage.obj = second;
                    handler.sendMessage(timeMessage);

                    //10秒采集一次坐标
                    if (second % collectDuring == 0) {
                        Message collectMessage = new Message();
                        collectMessage.what = MSG_COLLECT_POINT;
                        handler.sendMessage(collectMessage);
                    }
                }
            });
        }

        public void onServiceDisconnected(ComponentName name) {
        }
    }

    //每10采集一次坐标
    private void collectPoint() {
        GeoPoint point = locateCurrentLocation(null);
        if (point == null) {
            ToastUtils.show("无法获取当前位置，请检查是否开启GPS位置信息");
            return;
        }
        //跟上一个点比较，距离小于tolerance米或大于maxTolerance不上报
        if (lastReportPoint == null) {
            lastReportPoint = new ReportPointEntity(formatPoint(point.getLatitudeE6()), formatPoint(point.getLongitudeE6()), CustomUtils.getUUID(), "-1");
            toReportPoint = lastReportPoint;
        } else {
            try {
                int lastLongitude = (int) (Double.parseDouble(lastReportPoint.getLongitude()) * 1E6);
                int lastLatitude = (int) (Double.parseDouble(lastReportPoint.getLatitude()) * 1E6);
                GeoPoint lastGeoPoint = new GeoPoint(lastLatitude, lastLongitude);
                double distance = MulchUtil.calDistance(point, lastGeoPoint);
                LogUtils.v("gogogo distance = " + distance);

                lastReportPoint = new ReportPointEntity(formatPoint(point.getLatitudeE6()), formatPoint(point.getLongitudeE6()), CustomUtils.getUUID(), distance + "");
                if (distance >= tolerance && distance <= maxTolerance) {
                    toReportPoint = lastReportPoint;
                } else {
                    toReportPoint = null;
                }
            } catch (Exception e) {
                e.printStackTrace();
                toReportPoint = null;
            }
        }
        // 采集坐标在地图上画点  新需求不画点，暂时保留注释
//        MulchUtil.addTrajectoryMulch(getApplicationContext(), map_view, point);

    }

    //上报坐标
    private void reportPoint() {
        LogUtils.v("gogogo report point = " + (toReportPoint == null));
        if (toReportPoint != null) {
            requestReportPoint(toReportPoint);
            requestPoints.add(toReportPoint);
        }
    }

    private void searchGeoDecode(GeoPoint geoPoint) {
        loadingDialog.show();
        // 开始搜索
        if (mGeoDecode == null) {
            mGeoDecode = new TGeoDecode(this);
        }
        if (geoPoint != null) {
            mGeoDecode.search(geoPoint);
        } else {
            loadingDialog.dismiss();
            ToastUtils.show("查询地址失败，请重试");
        }
    }

    @Override
    public void onGeoDecodeResult(TGeoAddress addr, int errCode) {
        loadingDialog.dismiss();
        if (errCode != TErrorCode.OK) {
            return;
        }
        if (addr == null) {
            return;
        }
        //结束巡查解析的地址
        String stopPatrolAddress = addr.getAddress();
        if (TextUtils.isEmpty(stopPatrolAddress)) {
            ToastUtils.show("查询地址失败，请重试");
            return;
        }
        LogUtils.v("gogogo stop patrol address = " + stopPatrolAddress);
        InspectionRecordActivity.start(this, taskRecordId, stopPatrolPoint, stopPatrolAddress);
        finish();
    }

    @Override
    public boolean handleMessage(Message msg) {
        switch (msg.what) {
            case MSG_RESET_TIME:
                resetTimeTab((Integer) msg.obj);
                break;
            case MSG_COLLECT_POINT:
                //采集位置
                collectPoint();
                // 上报位置
                reportPoint();
                break;
            default:
                break;
        }
        return false;
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void webRefreshEvent(WebRefreshEvent event) {
        HashMap<String, String> params = new HashMap<>();
        params.put("Token", CustomUtils.getToken());
        ((ForestCampTaskPresenter) presenter).getMyForestZone(params, true);
    }

}
